import { createRouter, createWebHistory } from "vue-router";

const routes = [
    {
        path: '/',
        redirect: '/dashboard'
    },
    {
        path: '/dashboard',
        component: () => import('@/layout/Dashboard.vue'),
        redirect: '/dashboard/admin',
        name: 'Dashboard',
        children: [
            {
                path: '/dashboard',
                meta: {
                    title: '系统管理',
                    icon: 'Setting'
                },
                children: [
                    {
                        path: '/dashboard/admin',
                        component: () => import('@/views/admin/index.vue'),
                        meta: {
                            title: '用户管理',
                            icon: 'User'
                        }
                    },
                    {
                        path: '/dashboard/profile',
                        component: () => import('@/views/profile/index.vue'),
                        meta: {
                            title: '个人资料',
                            icon: 'Postcard'
                        }
                    },
                ]
            },
            {
                path: '/dashboard',
                meta: {
                    title: '商品管理',
                    icon: 'ShoppingBag'
                },
                children: [
                    {
                        path: '/dashboard/category',
                        component: () => import('@/views/category/index.vue'),
                        meta: {
                            title: '商品分类',
                            icon: 'Help'
                        }
                    },
                    {
                        path: '/dashboard/product',
                        component: () => import('@/views/product/index.vue'),
                        meta: {
                            title: '商品',
                            icon: 'Goods'
                        }
                    },
                ]
            },
        ]
    },
    {
        path: '/login',
        component: () => import('@/views/login/index.vue')
    },
    {
        path: '/register',
        component: () => import('@/views/register/index.vue')
    },
]

export default createRouter({
    routes,
    history: createWebHistory()
})